package com.lbs.until;

/**
 * @author Administrator
 * @date 2021/5/18 21:54
 * @description
 **/
public class PageUntil {
    private int curPage;            //当前页
    private int prevPage;           //上一页
    private int nextPage;           //下一页
    private int endPage;            //尾页
    private int rows;               //总记录数
    private int pageSize;           //页容量
    private int startIndex;         //每一页起始行下标


    public PageUntil(int rows,String curPage){
        pageSize = 6;

    }

    // 初始化当前页数
    public void initCurPage(String curPage){

        if (curPage!=null){
            this.curPage = Integer.valueOf(curPage);
        }else {
            this.curPage = 1;
        }

    }

    // 初始化上一页数
    public void initPrevPage(){
        if (curPage>1){
            pageSize = curPage - 1;
        }else {
            pageSize = 1;
        }
    }

    // 初始化下一页
    public void initNextPage(){
        if (curPage<endPage){
            nextPage = curPage+1;
        }else {
            nextPage = endPage;
        }
    }

    // 初始化尾页
    public void initEndPage(){
        if (rows%pageSize==0){
            endPage = rows/pageSize;
        }else {
            endPage = rows/pageSize+1;
        }
    }

    // 初始化起始行下标
    public void initStartIndex(){
        startIndex = (curPage - 1)*pageSize;
    }

    public int getCurPage() {
        return curPage;
    }

    public void setCurPage(int curPage) {
        this.curPage = curPage;
    }

    public int getPrevPage() {
        return prevPage;
    }

    public void setPrevPage(int prevPage) {
        this.prevPage = prevPage;
    }

    public int getNextPage() {
        return nextPage;
    }

    public void setNextPage(int nextPage) {
        this.nextPage = nextPage;
    }

    public int getEndPage() {
        return endPage;
    }

    public void setEndPage(int endPage) {
        this.endPage = endPage;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getStartIndex() {
        return startIndex;
    }

    public void setStartIndex(int startIndex) {
        this.startIndex = startIndex;
    }
}
